package com.demo;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Base64;

public class DmeoEnumMain {
    public static void main(String[] args) {
        String filePath = "/Users/xuyihang/Downloads/00001111.jpg";
        byte[] bytes = null;
        try {
            FileInputStream fileInputStream = new FileInputStream(filePath);
            bytes = new byte[fileInputStream.available()];
            fileInputStream.read(bytes);
            String s = Base64.getEncoder().encodeToString(bytes);
            System.out.println(s);
            saveImages("JK001", s, "/Users/xuyihang/Downloads/log/server/image/timeOut/");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void saveImages(String workNum, String imageBase, String filePaths) throws IOException {
        String filePath = filePaths + workNum + ".jpg";
        File file = new File(filePath);
        FileOutputStream fileInputStream = new FileOutputStream(file);
        byte[] decode = Base64.getDecoder().decode(imageBase);
        fileInputStream.write(decode);
        fileInputStream.close();
    }
}
